package net.zbus.loadbalance;

import net.zbus.ServiceHandler;
import net.zbus.WorkerPool;
import net.zbus.WorkerPoolConfig;
import net.zbus.ZMsg;


public class WorkerExample {
 
	public static void main(String[] args) {  
		WorkerPoolConfig config = new WorkerPoolConfig();
		config.setBrokers(new String[]{"127.0.0.1:15555"});
		config.setService("helloworld"); 
		
		
		WorkerPool pool = new WorkerPool(config);
		pool.run(1, new ServiceHandler() { 
			@Override
			public ZMsg handleRequest(ZMsg request) {  
				request.pushBack(""+System.currentTimeMillis());
				try {
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return request;
			}
		}); 
	}

}
